package com.aion.jirc.irc.wrappers;

import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * Date: 11-02-18
 * Time: 09:13
 *
 * @author Aion
 */
public class Channel {

    private ArrayList<User> admins;
    private ArrayList<User> founders;
    private ArrayList<User> halfops;
    private ArrayList<User> ops;
    private ArrayList<User> voices;
    private ArrayList<User> regs;

    private ArrayList<Mode> modes;

    private String topic;

    public Channel(String topic) {
        this.topic = topic;
    }

    /**
     * Gets the admins of this channel.
     *
     * @return the admins
     */
    public User[] getAdmins() {
        if (!admins.isEmpty()) {
            return admins.toArray(new User[admins.size()]);
        }
        return new User[0];
    }

    /**
     * Gets the founders of this channel.
     *
     * @return the founders
     */
    public User[] getFounders() {
        if (!founders.isEmpty()) {
            return founders.toArray(new User[founders.size()]);
        }
        return new User[0];
    }

    /**
     * Gets the half-operators of this channel.
     *
     * @return the half-operators
     */
    public User[] getHalfoperators() {
        if (!halfops.isEmpty()) {
            return halfops.toArray(new User[halfops.size()]);
        }
        return new User[0];
    }

    /**
     * Gets the modes of this channel.
     *
     * @return the modes
     */
    public Mode[] getModes() {
        if (modes.isEmpty()) {
            return modes.toArray(new Mode[modes.size()]);
        }
        return new Mode[0];
    }

    /**
     * Gets the operators of this channel.
     *
     * @return the operators
     */
    public User[] getOperators() {
        if (!ops.isEmpty()) {
            return ops.toArray(new User[ops.size()]);
        }
        return new User[0];
    }

    /**
     * Gets the regulars of this channel.
     *
     * @return the regulars
     */
    public User[] getRegulars() {
        if (regs.isEmpty()) {
            return regs.toArray(new User[regs.size()]);
        }
        return new User[0];
    }

    /**
     * Gets the topic of this channel.
     *
     * @return the topic of this channel
     */
    public String getTopic() {
        return topic;
    }

    /**
     * Gets the users of this channel.
     *
     * @return the users
     */
    public User[] getUsers() {
        ArrayList<User> users = new ArrayList<User>();
        for (User user : getRegulars()) users.add(user);
        for (User user : getVoices()) users.add(user);
        for (User user : getHalfoperators()) users.add(user);
        for (User user : getOperators()) users.add(user);
        for (User user : getAdmins()) users.add(user);
        for (User user : getFounders()) users.add(user);
        return users.toArray(new User[users.size()]);
    }

    /**
     * Gets the voices of this channel.
     *
     * @return the voices
     */
    public User[] getVoices() {
        if (!voices.isEmpty()) {
            return voices.toArray(new User[voices.size()]);
        }
        return new User[0];
    }

}
